package com.apigen.platform.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;

/**
 * 数据库连接请求DTO
 *
 * @author API Generator Platform
 * @since 2025-09-24
 */
@Data
@Schema(description = "数据库连接配置参数")
public class DatabaseConnectionRequest {

    @NotBlank(message = "数据库类型不能为空")
    @Schema(description = "数据库类型", example = "MYSQL", allowableValues = {"MYSQL", "POSTGRESQL", "ORACLE", "SQL_SERVER"})
    private String databaseType;

    @NotBlank(message = "主机地址不能为空")
    @Schema(description = "数据库主机地址", example = "localhost")
    private String host;

    @NotNull(message = "端口号不能为空")
    @Min(value = 1, message = "端口号必须大于0")
    @Max(value = 65535, message = "端口号不能超过65535")
    @Schema(description = "数据库端口", example = "3306")
    private Integer port;

    @NotBlank(message = "数据库名不能为空")
    @Schema(description = "数据库名称", example = "test_db")
    private String database;

    @NotBlank(message = "用户名不能为空")
    @Schema(description = "数据库用户名", example = "root")
    private String username;

    @Schema(description = "数据库密码", example = "password")
    private String password;

    @Schema(description = "字符集", example = "utf8mb4")
    private String charset = "utf8mb4";

    @Schema(description = "连接超时时间(秒)", example = "30")
    private Integer timeout = 30;

    @Schema(description = "是否使用SSL", example = "false")
    private Boolean useSSL = false;

    @Schema(description = "表名过滤(支持通配符)", example = "sys_*,gen_*")
    private String tableFilter;

    @Schema(description = "连接参数(JSON格式)", example = "{\"serverTimezone\":\"Asia/Shanghai\"}")
    private String connectionParams;
}











